﻿using SharpDX.DirectWrite;

namespace Ensemble_Windows
{
    /// <summary>
    /// 文字类
    /// </summary>
    public class Text : Direct2D1Render
    {
        /// <summary>
        /// <see cref="FactoryDWrite"/>
        /// </summary>
        public new Factory FactoryDWrite { get; private set; }
        /// <summary>
        /// 基本配置
        /// </summary>
        public Configuration Configuration { get; private set; }
        /// <summary>
        /// 文字
        /// </summary>
        public string Value { get; private set; }
        /// <summary>
        /// <see cref="TextFormat"/>
        /// </summary>
        public TextFormat TextFormat { get; private set; }
        /// <summary>
        /// <see cref=" TextAntialiasMode"/>
        /// </summary>
        public TextAntialiasMode TextAntialiasMode { get; private set; }
        /// <summary>
        /// <see cref="TextLayout"/>
        /// </summary>
        public TextLayout TextLayout { get; private set; }

        /// <summary>
        /// 创建文字
        /// </summary>
        /// <param name="factoryDWrite">一般在Initialize里直接传值</param>
        /// <param name="configuration">基本配置</param>
        /// <param name="text">文字</param>
        public Text(Factory factoryDWrite, Configuration configuration, string text)
            : this(factoryDWrite, configuration, text,
            TextHelper.GetFormat(factoryDWrite), TextAntialiasMode.Cleartype,
            TextHelper.GetLayout(factoryDWrite, text, configuration, TextHelper.GetFormat(factoryDWrite)))
        { }

        /// <summary>
        /// 创建文字
        /// </summary>
        /// <param name="factoryDWrite">一般在Initialize里直接传值</param>
        /// <param name="configuration">基本配置</param>
        /// <param name="text">文字</param>
        /// <param name="textFormat">文字格式</param>
        /// <param name="mode">用于文本时需要抗锯齿渲染模式</param>
        /// <param name="textlayout">文本块</param>
        public Text(Factory factoryDWrite, Configuration configuration, string text, TextFormat textFormat, TextAntialiasMode mode, TextLayout textlayout)
        {
            FactoryDWrite = factoryDWrite;
            Configuration = configuration;
            Value = text;
            TextFormat = textFormat;
            TextAntialiasMode = mode;
            TextLayout = textlayout;
        }
    }
}
